<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            width: 500px;
            margin: 100px auto;
            border-collapse: collapse;
            text-align: center;
        }

        td,
        th {
            border: 1px solid #333;
        }

        thead {
            height: 40px;
            background-color: #ccc;
        }
    </style>
</head>

<body>
  <table cellspacing="0">
    <thead>
        <tr>
            <th>姓名</th>
            <th>科目</th>
            <th>成绩</th>
            <th>删除</th>
           </tr>
    </thead>
    <tbody>

    </tbody>
  </table>
    <script>
     var datas = [
        {
            name: '卫英络',
            subject: 'JavaScript',
            score: 100
    },
    {
            name: '红缨',
            subject: 'JavaScript',
            score: 96
    },
    {
            name: '博恒',
            subject: 'JavaScript',
            score: 88
    },
    {
            name: '明宇',
            subject: 'JavaScript',
            score: 85
    },
    {
            name: '大猪蹄子',
            subject: 'JavaScript',
            score: 00
    },
     ];
     //2.往tbody 里边创建行： 有几个人（通过数组长度）就创建几行
     var tbody = document.querySelector('tbody');
     for(var i = 0; i < datas.length; i++) {
        var tr = document.createElement('tr');
        tbody.appendChild(tr)
        for(var k in datas[i]) {
            var td = document.createElement('td');
            td.innerHTML = datas[i][k];
            tr.appendChild(td);
        }
        var td = document.createElement('td');
        td.innerHTML = '<a href="javascript:;">删除</a>';
        tr.appendChild(td);
     }
     // fro( var k in obj) {
        //   k得到的是属性名
        //   obj[k] 得到是属性值
     //}
    </script>
</body>

</html>